package com.runa.monitor.platinterface.meter3_0.client;

import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;

import java.io.IOException;
import java.util.concurrent.ExecutionException;


public class Client {
    public static void main(String[] args) {
        StandardWebSocketClient client = new StandardWebSocketClient();
        ClientHandler handler = new ClientHandler();
        //连接带参数
//        String url = "ws://localhost:8080/sp2?name=quit";
        String url = "ws://127.0.0.1:8000/comm/websoc";
//        String url = "ws://124.222.224.186:8800";
        ListenableFuture<WebSocketSession> future = client.doHandshake(handler, url);
        try (WebSocketSession session = future.get()) {
            session.sendMessage(new TextMessage("发送数据111"));
            session.sendMessage(new TextMessage("发送数据2222"));
        } catch (InterruptedException e) {
            
        } catch (ExecutionException e) {
            
        } catch (IOException e) {
            
        }
    }
}
